/** \file
* Platform-independent implementations for the debug console class.
* This file is part of Chorus, available at
* http://code.google.com/p/chorus-twitter/ . This file and all associated files
* and derivative works are bound by the terms of the LGPL 3.0 license,
* available at http://www.gnu.org/licenses/lgpl-3.0-standalone.html .
* \par Subversion URL:
* \$URL: http://chorus-twitter.googlecode.com/svn/branches/cpp/src/tests/Test.hpp $
* \version \$Rev: 152 $
* \date    \$Date: 2010-04-06 07:35:13 +0000 (Tue, 06 Apr 2010) $
*/

#pragma once

#include <list>

#include "system/DebugConsole.hpp"

/// The generic abstract test class.
class Test
{
protected:
	/// The constructor. Cannot be called directly.
	Test() {}
public:
	/// Perform the test.
	/// \return True for success.
	virtual bool test() = 0;
};

/// The test set class.
class TestSet
{
public:
	/// The destructor.
	~TestSet();

public:
	/// Perform the tests.
	/// \return True if all tests succeeded.
	bool doTests();

	/// Add a test. TestType is the type of test to add.
	template <typename TestType>
	void addTest()
	{
		TestType *const newtest = new TestType;
		if (!newtest)
		{
			PDEBUG("new failed");
			return;
		}
		tests.push_back(newtest);
	}

private:
	/// The test list type.
	typedef std::list<Test*> TestList;
	/// The test list iterator type.
	typedef TestList::iterator TestListIter;

	/// The list of tests.
	TestList tests;
};
